﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Collections;
using System.ComponentModel;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace Z16.BLI
{
    public class LoginUsr
    {
        #region "Variaveis"

        private int intCodUsr;
        public int IntCodUsr
        {
            get { return intCodUsr; }
            set { intCodUsr = value; }
        }

        private string strLogin;
        public string StrLogin
        {
            get { return strLogin; }
            set { strLogin = value; }
        }

        private string strSenha;
        public string StrSenha
        {
            get { return strSenha; }
            set { strSenha = value; }
        }

        private int intCodPerfil;
        public int IntCodPerfil
        {
            get { return intCodPerfil; }
            set { intCodPerfil = value; }
        }

        #endregion
        
        #region "Metodos"

        public List<LoginUsr> listarLoginUsuario(string strLogin, string strSenha)
        {
            List<LoginUsr> allLogin = new List<LoginUsr>();

            SqlParameter[] pms =
                    {
                        new SqlParameter("@LOGIN", strLogin),
                        new SqlParameter("@SENHA", strSenha)
                    };

            SqlDataReader drUsuario = SqlHelper.ExecuteReader(SqlHelper.GetSQLConnection(), CommandType.StoredProcedure, "procSelLogin", pms);
            while (drUsuario.Read())
            {
                LoginUsr LoginUsr = new LoginUsr();
                LoginUsr.IntCodUsr = Convert.ToInt32(drUsuario["COD_USUARIO"].ToString());
                LoginUsr.intCodPerfil = Convert.ToInt32(drUsuario["COD_PERFIL"].ToString());
                allLogin.Add(LoginUsr);
            }
            return allLogin;
        }

        #endregion
    }
}